﻿/************************************************************************

	File:			args.h
	Version:		1.0
	Changes:		A
	Author:			Stanley Lau
	Date:			2010.07.30
	Purpose:		Arguments process functions declaration

************************************************************************/

#ifndef _ARGS_H_
#define _ARGS_H_

#include <stdlib.h>
#include <string.h>
#include "args_cross.h"

#define MIN_ARG_LEN 3
#define ARG_PREFIX_a "--"
#define ARG_DELIMI_a "="
#define ARG_PREFIX_w L"--"
#define ARG_DELIMI_w L"="

typedef struct _tagArgItem_a
{
	char*			pstrItem;
	char*			pstrItemName;
	char*			pstrItemValue;
	
} KArgItem_a, *PKArgItem_a;

typedef struct _tagArgs_a
{
	PKArgItem_a		pArgItem;
	unsigned int	nArgItemCount;

} KArgs_a, *PKArgs_a;

typedef struct _tagArgItem_w
{
	wchar_t*		pstrItem;
	wchar_t*		pstrItemName;
	wchar_t*		pstrItemValue;

} KArgItem_w, *PKArgItem_w;

typedef struct _tagArgs_w
{
	PKArgItem_w		pArgItem;
	unsigned int	nArgItemCount;

} KArgs_w, *PKArgs_w;

ARGS_CPP ARGS_FUNC_CONTROL PKArgs_a GetArgs_a( int argn, char** argv );
ARGS_CPP ARGS_FUNC_CONTROL int ReleaseArgs_a( PKArgs_a pArgs );
ARGS_CPP ARGS_FUNC_CONTROL const char*	GetStringItem_a( PKArgs_a pArgs, const char* pstrName );
ARGS_CPP ARGS_FUNC_CONTROL int GetIntItem_a( PKArgs_a pArgs, const char* pstrName );
ARGS_CPP ARGS_FUNC_CONTROL int HasItem_a( PKArgs_a pArgs, const char* pstrName );

ARGS_CPP ARGS_FUNC_CONTROL PKArgs_w GetArgs_w( int argn, wchar_t** argv );
ARGS_CPP ARGS_FUNC_CONTROL int ReleaseArgs_w( PKArgs_w pArgs );
ARGS_CPP ARGS_FUNC_CONTROL const wchar_t* GetStringItem_w( PKArgs_w pArgs, const wchar_t* pstrName );
ARGS_CPP ARGS_FUNC_CONTROL int GetIntItem_w( PKArgs_w pArgs, const wchar_t* pstrName );
ARGS_CPP ARGS_FUNC_CONTROL int HasItem_w( PKArgs_w pArgs, const wchar_t* pstrName );

static int ParseArgs_w( PKArgs_w pArgs, int argn, wchar_t** argv );
static PKArgItem_w FindItem_w( PKArgs_w pArgs, const wchar_t* pstrName );
static int ParseArgs_a( PKArgs_a pArgs, int argn, char** argv );
static PKArgItem_a FindItem_a( PKArgs_a pArgs, const char* pstrName );
#endif
//Last line for linux

